﻿using System;
using System.Collections.Generic;
using System.Text;
using Elota.SCAQGL.Models;
using Elota.SCAQGL.DAL;


namespace Elota.SCAQGL.BLL
{
    public class DBSchemaManager
    {
        #region 数据表管理
        private static DBSchemaManager instance;
        private static object obj = new object();
        public static DBSchemaManager Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (obj)
                    {
                        if (instance == null)
                            instance = new DBSchemaManager();
                    }
                }
                return instance;
            }
        }
        #endregion
        /// <summary>
        /// 保存表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Save(DBSchemaTable model)
        {
            return false;
        }
        /// <summary>
        /// 保存字段
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Save(DBSchemaField model)
        {
            return false;
        }
        /// <summary>
        /// 根据父级ID 获取表信息
        /// </summary>
        /// <param name="sParentID"></param>
        /// <returns></returns>
        public IList<DBSchemaTable> GetScheamTablesByParentID(string sParentID)
        {
            string strWhere = string.Format(" Where ParentID={0} ", sParentID);
            return DBSchemaTableDAL.Instance.GetModels(strWhere);
        }
        /// <summary>
        /// 根据表ID 获取字段集合
        /// </summary>
        /// <param name="sTableID"></param>
        /// <returns></returns>
        public IList<DBSchemaField> GetDBScheamFieldByTableID(string sTableID)
        {
            string strWhere = string.Format(" Where TableID={0}", sTableID);
           return  DBSchemaFieldDAL.Instance.GetModels(strWhere);
        }
    }
}
